import { _decorator, Component, Node } from 'cc';
import { Constants } from "../data/Constants";
import { TopicManger } from "./TopicManger";
import { ProgressMgr } from "./ProgressMgr";
import { AudioManager } from "../audio/AudioManager";
const { ccclass, property } = _decorator;

@ccclass('TopicSelect')
export class TopicSelect extends Component {

    start() {

    }


    select(enevt, type) {
        console.log(type, 'type')
        // if (TopicManger.btnStatus) return
        // TopicManger.btnStatus = true
        switch (type) {
            case '1':
                console.log('点击了错误按钮')
                if (!TopicManger.quiz[TopicManger.quizIndex].result) {
                    // 答对
                    this.correctAnswer()
                } else {
                    this.wrongAnswer()
                }
                break;
            default:
                console.log('点击了正确按钮')
                if (TopicManger.quiz[TopicManger.quizIndex].result) {
                    // 答对
                    this.correctAnswer()
                } else {
                    this.wrongAnswer()
                }
                break;
        }
        this.handleSelect()
    }

    // 答对
    correctAnswer() {
        AudioManager.playSound(Constants.AudioSource.CORRECT);
        TopicManger.prototype.correctAnswer()
    }

    // 答错
    wrongAnswer() {
        AudioManager.playSound(Constants.AudioSource.MISTAKE);
        console.log('答错了')
        TopicManger.prototype.wrongAnswer()
    }

    handleSelect () {
        ProgressMgr.timerOver = true
    }
    
    update(deltaTime: number) {

    }
}





